

# websocketAdapter

<div class="api-docs__separator" data-reactroot="">

---

</div><div class="api-docs__import" data-reactroot="">

```ts
import { websocketAdapter } from "@hyper-fetch/sockets"
```

</div><div class="api-docs__section">

## Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [adapter/adapter.websocket.ts:21](https://github.com/BetterTyped/hyper-fetch/blob/cc329b91/packages/sockets/src/adapter/adapter.websocket.ts#L21)

</p><div class="api-docs__section">

## Preview

</div><div class="api-docs__preview fn">

```ts
websocketAdapter(socket, DO_NOT_USE)
```

</div><div class="api-docs__section">

## Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="socket"><td class="api-docs__param-name required">

### socket 

`Required`

</td><td class="api-docs__param-type">

`Socket<SocketAdapterType<WSAdapterOptionsType, MessageEvent<SocketData<any>>, never, never>>`

</td></tr><tr param-data="DO_NOT_USE"><td class="api-docs__param-name optional">

### DO\_NOT\_USE 

`Optional`

</td><td class="api-docs__param-type">

`{ adapterExtra?: MessageEvent<SocketData<any>>; adapterOptions?: WSAdapterOptionsType; emitterOptions?: never; listenerOptions?: never }`

</td></tr></tbody></table></div><div class="api-docs__section">

## Returns

</div><div class="api-docs__returns">

```ts
{
  connect: () => void;
  connecting: boolean;
  disconnect: () => void;
  emit: (eventMessageId: string, emitter: EmitterInstance, ack?: EmitterAcknowledgeType<any, SocketAdapterType<WSAdapterOptionsType, MessageEvent<SocketData<any>>, never, never>>) => void;
  listen: (listener: Listener<any, any, SocketAdapterType<WSAdapterOptionsType, MessageEvent<SocketData<any>>, never, never>, false>, callback: ListenerCallbackType<SocketAdapterType<WSAdapterOptionsType, MessageEvent<SocketData<any>>, never, never>, any>) => RemoveListenerCallbackType;
  listeners: Map<string, Map<ListenerCallbackType<SocketAdapterInstance, any>, VoidFunction>>;
  open: boolean;
  reconnect: () => void;
  reconnectionAttempts: number;
  removeListener: (endpoint: string, callback: (...args: any) => void) => void;
}
```

</div>